

//
//  ZZDataFXViewModel.m
//  新项目
//
//  Created by 刘耀宗 on 2017/3/15.
//  Copyright © 2017年 刘耀宗. All rights reserved.
//

#import "ZZDataFXViewModel.h"

@implementation ZZDataFXViewModel
+(instancetype)shareViewModel{
    static id instance;
    static  dispatch_once_t once;
    dispatch_once(&once, ^{
        instance=[[self alloc] init];
    });
    return instance;
    
}
//商品数据分析
//首页查询
-(void)DataFenXiWithunsalableDay :(NSString *)unsalableDay andsTime:(NSString *)sTime andEtime:(NSString *)eTime andsaleNum:(NSString *)saleNum andpartsName:(NSString *)partsName andsupplierName:(NSString *)supplierName andcompanyID:(NSString *)companyID andcompanyFID:(NSString *)companyFID andpageIndex:(NSString *)pageIndex andpageSize:(NSString *)pageSize andflag:(NSString *)flag andSuccess:(void (^)(NSDictionary *result))success andFailer:(void (^)())failer
{
    NSMutableDictionary *strDic=[NSMutableDictionary dictionary];

    [strDic setKey:@"unsalableDay" forValue:unsalableDay];//滞销天数 int 类型
    [strDic setKey:@"sTime" forValue:sTime];//开始时间
    [strDic setKey:@"eTime" forValue:eTime];//结束时间
    [strDic setKey:@"saleNum" forValue:saleNum];//热销数量 int 类型
    [strDic setKey:@"partsName" forValue:partsName];////配件名称
    [strDic setKey:@"supplierName" forValue:supplierName];//供应商名称
    [strDic setKey:@"companyID" forValue:companyID];////企业ID  bigint 类型
    [strDic setKey:@"companyFID" forValue:companyFID];//企业父级ID  bigint 类型
    [strDic setKey:@"pageIndex" forValue:pageIndex];//页码
    [strDic setKey:@"pageSize" forValue:pageSize];////页大小
    [strDic setKey:@"flag" forValue:flag];////查询方式
    //    HotGoods：商品热销分析、
    //    UnsalableGoods：商品滞销分析、
    //    PurchasePrice：商品进价分析、
    //    SellingPrice：商品销价分析、
    //    ReturnGoods：供应商退货分析
    NSString *jsonStr=[WHJSON jsonStringWithObject:strDic];
    
    NSMutableDictionary *dic=[NSMutableDictionary dictionary];
    [dic setKey:@"data" forValue:jsonStr];
    
    [YBHttpTool post:@"api/CmpReporting/ProductAnalysis/GetAnalysisData" params:dic success:^(NSDictionary *obj) {
        DLog(@"=====%@",obj);
        if ([obj isKindOfClass:[NSNull class]] || obj==nil) {
            DLog(@"返回值为空");
            return ;
        }
        success(obj);
        
    } failure:^(NSError *error) {
        failer();
    }];
    
}

@end
